
package security

import (
    "encoding/xml"
	"github.com/gomydodo/wxencrypter"
)

func EncrypterStruct(Token,EncodingAesKey,AppId string,req interface{}) ([]byte, error) {
	msgXml, err := xml.Marshal(req)
	if err != nil {
		return []byte{}, err
	}
	e, err := wxencrypter.NewEncrypter(Token, EncodingAesKey, AppId)
	if err != nil {
		return []byte{}, err
	}
	b, err := e.Encrypt(msgXml)
	if err != nil {
		return []byte{}, err
	}
	return b, nil
}
